<?
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if ( ! function_exists('getMenu'))
{
   function getMenu()
   {
      $ci=& get_instance();
      $ci->load->library('session');
      $ci->load->helper('url');
      $output = '<ul id="mainmenu">';

      //Grab current user
      $current_user = $ci->session->all_userdata();

      //Check if analyst, output menu
      $ci->load->model('Analyst_model','analyst');
      $result = $ci->analyst->get($current_user["UserID"]);
      if( count( $result ) != 0)
         $output .=$ci->load->view('analystmenuview','', TRUE);
      

      //Check if CR, output menu
      $ci->load->model('Customerrep_model','customerrep');
      $result = $ci->customerrep->get($current_user["UserID"]);
      if( count( $result ) != 0)
         $output .=$ci->load->view('crmenuview','', TRUE);

      //Check if CR, output menu
      $ci->load->model('Irteam_model','irteam');
      $result = $ci->irteam->get($current_user["UserID"]);
      if( count( $result ) != 0)
         $output .= $ci->load->view('irtmenuview','',TRUE);

      //Output Manager Menu
      if($current_user["IsManager"] == 1)
         $output .= $ci->load->view('managermenuview','',TRUE);

      //Output user menu for everyone
      $output .= $ci->load->view('userview','',TRUE);
      $output .= "</ul>";


      return $output;

      

   }
}
?>
